package com.zrwl.poscloud.xo.service.impl;
import com.zrwl.poscloud.base.entity.StudentScoreBath;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zrwl.poscloud.base.enums.EStatus;
import com.zrwl.poscloud.base.superI.SuperServiceImpl;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.xo.global.MessageConf;
import com.zrwl.poscloud.xo.global.SQLConf;
import com.zrwl.poscloud.xo.global.SysConf;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import com.zrwl.poscloud.xo.mapper.StudentScoreBathMapper;
import com.zrwl.poscloud.xo.service.StudentScoreBathService;
import com.zrwl.poscloud.xo.vo.StudentScoreBathVO;

import javax.annotation.Resource;

/**
 * 成绩发布 服务实现类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-03-10
 */
@Service
public class StudentScoreBathServiceImpl extends SuperServiceImpl<StudentScoreBathMapper,StudentScoreBath> implements StudentScoreBathService {

    @Autowired
    private StudentScoreBathService studentScoreBathService;
    @Resource
    private StudentScoreBathMapper studentScoreBathMapper;
    @Override
    public IPage<StudentScoreBathVO> getPageList(StudentScoreBathVO studentScoreBathVO){
       Page<StudentScoreBath> page = new Page<>();
       page.setCurrent(studentScoreBathVO.getCurrentPage());
       page.setSize(studentScoreBathVO.getPageSize());
       IPage<StudentScoreBathVO> pageList = studentScoreBathMapper.getPageList(page, studentScoreBathVO);
       List<StudentScoreBathVO> list = pageList.getRecords();
       pageList.setRecords(list);
       return pageList;
}
    @Override
    public List<StudentScoreBath> getAllList(StudentScoreBathVO studentScoreBathVO){
        QueryWrapper<StudentScoreBath> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne(SQLConf.STATUS, EStatus.DISABLED);
        queryWrapper.orderByAsc(SQLConf.CREATE_TIME);
        List<StudentScoreBath> list = studentScoreBathService.list(queryWrapper);
        return list;
}
    @Override
    public String add(StudentScoreBathVO studentScoreBathVO){
        StudentScoreBath entity = new StudentScoreBath();
        BeanUtils.copyProperties(studentScoreBathVO, entity, SysConf.STATUS);
        entity.insert();
        studentScoreBathVO.setUid(entity.getUid());
        return ResultUtil.successWithMessage(MessageConf.INSERT_SUCCESS);}
    @Override
    public String edit(StudentScoreBathVO studentScoreBathVO){
        StudentScoreBath entity = studentScoreBathService.getById(studentScoreBathVO.getUid());
        BeanUtils.copyProperties(studentScoreBathVO, entity);
        entity.updateById();
        return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}
    @Override
    public String delete(StudentScoreBathVO studentScoreBathVO){
        StudentScoreBath entity = studentScoreBathService.getById(studentScoreBathVO.getUid());
        entity.setStatus(EStatus.DISABLED);
        entity.updateById();
        return ResultUtil.successWithMessage(MessageConf.UPDATE_SUCCESS);
}

    @Override
    public IPage<StudentScoreBathVO> getStudentScoreList(StudentScoreBathVO studentScoreBathVO) {
        Page<StudentScoreBath> page = new Page<>();
        page.setCurrent(studentScoreBathVO.getCurrentPage());
        page.setSize(studentScoreBathVO.getPageSize());
        IPage<StudentScoreBathVO> pageList=studentScoreBathMapper.getStudentScoreList(page,studentScoreBathVO);
        List<StudentScoreBathVO> list = pageList.getRecords();
        pageList.setRecords(list);
        return pageList;
    }
}
